import React, { useState, useEffect } from 'react'
import ReactDOM from 'react-dom'

function HocPopup(App) {
  let [val, setVal] = useState(false)
  // useEffect(() => {
  // if (props.isPopup) {
  //   document.body.appendChild(dom)
  // } else {
  let popupDom = document.getElementsByClassName('popupDom')
  if (popupDom) {
    // document.body.removeChild(popupDom)
  }
  // }
  // }, [])

  let dom = document.createElement('div');
  dom.classList.add('popupDom')
  document.body.appendChild(dom)


  return () => {
    return (
      <div className="usePopup">
        {
          ReactDOM.createPortal(<>{
            App.map((Item, i) => <Item key={i} />)
          }</>, dom)
        }
      </div>
    )
  }
}
export default HocPopup;